using System;
using System.Data;
using System.Collections.Generic;
using Mono.Data.Sqlite;

namespace akdatabase
{
	public static class setup
	{
		public static IDbConnection dbcon;
		public static void initConnection()
		{
			// creates a new connection to the file.
			dbcon = (IDbConnection) new SqliteConnection("URI=file:" + akvars.parameters.database.path + akvars.parameters.database.filename);
			dbcon.Open();
		}
		public static void createTables()
		{
			// creates the tables if they do not exist already.
			IDbCommand dbcmd = dbcon.CreateCommand();
			dbcmd.CommandText = "CREATE TABLE IF NOT EXISTS movies ( title TEXT, path TEXT )";
			dbcmd.ExecuteNonQuery();
		}
		public static void addDummyItems()
		{
			List<string> items = new List<string>(){ "Cold Prey","Cold Prey 2","Translymania" };
			IDbCommand dbcmd = dbcon.CreateCommand();
			
			foreach (string s in items)
			{
				dbcmd.CommandText = "INSERT INTO movies VALUES ('" + s + "','" + s + ".mkv')";
				dbcmd.ExecuteNonQuery();
			}
		}
	}
}
